<?php

declare(strict_types=1);

/**
 * @Author:     Frank
 * @contact     frank_hhm@163.com
 * @Date:       2023-02-06 21:31:29
 * @Last Modified time: 2023-02-06 21:38:04
 */

namespace app\common\factory\store\goods\source;

use app\common\enum\store\order\SourceEnum;

/**
 * 商品来源工厂类
 * Class Factory
 * @package app\common\factory\goods\source
 */
class Factory extends \app\common\factory\BaseFactory
{
    // 订单来源的结算台服务类
    private static $class = [
        SourceEnum::MASTER => 'Master',
    ];

    /**
     * 根据订单来源获取商品库存类
     * @param int $orderSource
     * @return mixed
     */
    public static function getFactory($orderSource = SourceEnum::MASTER)
    {
        static $classObj = [];
        if (!isset($classObj[$orderSource])) {
            $className = __NAMESPACE__ . '\\' . static::$class[$orderSource];
            $classObj[$orderSource] = new $className();
        }
        return $classObj[$orderSource];
    }
}